package com.jbit.dm212.service.impl;

import com.jbit.dm212.common.RedisUtils;
import com.jbit.dm212.constance.Constant;
import com.jbit.dm212.service.RedisService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class RedisServiceImpl implements RedisService {
    @Resource
    private RedisUtils redisUtils;
    @Override
    public void sendSms(String phone,String code) {
        redisUtils.set(Constant.generaSmsKey(phone),code,300);
    }

    @Override
    public boolean checkSms(String phone) {
        return redisUtils.hasKey(Constant.generaSmsKey(phone));
    }

    @Override
    public String getCode(String phone) {
        return redisUtils.get(Constant.generaSmsKey(phone)).toString();
    }

    @Override
    public boolean delPhone(String phone) {
        return redisUtils.delete(Constant.generaSmsKey(phone));
    }


}
